/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package xmarti.vacaxm.client.sequence;

import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;

import javax.swing.event.ListSelectionEvent;
import xmarti.vacaxm.action.ImplSequence;
import xmarti.vacaxm.beans.maintenance.Animal;
import xmarti.vacaxm.beans.sequence.Sequence;
import xmarti.vacaxm.beans.sequence.SequenceType;
import xmarti.vacaxm.beans.sequence.StateDefault;
import xmarti.vacaxm.exception.ExceptionHibernateVacaxm;
import xmarti.vacaxm.utils.JTableXM;

import xmarti.vacaxm.utils.TDSLanguageUtils;
import xmarti.vacaxm.utils.TableModel;
import xmarti.vacaxm.utils.ValidarText;

/**
 *
 * @author xmarti
 */
public class JDNewSequence extends javax.swing.JDialog {
    private List sequences;    
    private JTableXM jTable; 
    private Animal animal; 
    private Sequence sequence; 
    private SequenceType sequenceType; 
    private StateDefault stateDefault; 
    private ImplSequence implSequence; 
    private Set<StateDefault> states; 
    /**
     * Creates new form JDNewSequence
     */
    public JDNewSequence(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    public JDNewSequence(java.awt.Frame parent, boolean modal, Animal animal) {
        super(parent, modal);
        initComponents();  
        jTextDuration.setDocument(new ValidarText(3,true));
        this.animal=animal;
        this.implSequence=new ImplSequence();               
        this.jTable= new JTableXM() {
            @Override
            public void handleSelectionEvent(ListSelectionEvent e) {
                 selectionEvent(e);
            }
        };
        this.jTable.setRowHeight(30);
        
        this.jScrollPaneTable.setViewportView(this.jTable);
        try {
            chargeSequenceType();
        } catch (ExceptionHibernateVacaxm ex) {
            Logger.getLogger(JDNewSequence.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    private void setDataSequence() throws ExceptionHibernateVacaxm{
         this.jLabelDescriptionSequence.setText(this.sequenceType.getDescription());
         this.jTable.chargeModel(this.getModel());
         
    }
    private void chargeSequenceType() throws ExceptionHibernateVacaxm{
        int id=-1; 
        if (jComboSequence.getSelectedIndex() > -1) {
            SequenceType c =(SequenceType) jComboSequence.getSelectedItem();
            id=c.getId();
        }
                
        jComboSequence.removeAllItems();
        jComboSequence.addItem(new SequenceType());                    
        for(SequenceType c:implSequence.getSequencesType())jComboSequence.addItem(c);                    
        if (id>-1 ){
            for(int i=0;i<jComboSequence.getItemCount();i++){
                SequenceType c = (SequenceType)jComboSequence.getItemAt(i);
                if (c.getId()==id){
                    jComboSequence.setSelectedIndex(i);
                    i=jComboSequence.getItemCount();
                }                        
            }
        }
    }
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabelSequences = new javax.swing.JLabel();
        jComboSequence = new javax.swing.JComboBox();
        jLabelSequences1 = new javax.swing.JLabel();
        jLabelSequences3 = new javax.swing.JLabel();
        jLabelSequences2 = new javax.swing.JLabel();
        jSeparator1 = new javax.swing.JSeparator();
        jScrollPaneTable = new javax.swing.JScrollPane();
        jLabelSequences4 = new javax.swing.JLabel();
        jTextDuration = new javax.swing.JTextField();
        jLabelSequences5 = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        jButtonExit = new javax.swing.JButton();
        jButtonSave2 = new javax.swing.JButton();
        jLabelDescriptionSequence = new javax.swing.JLabel();
        jLabelDescriptionState = new javax.swing.JLabel();
        jLabelSequences6 = new javax.swing.JLabel();
        jTextName = new javax.swing.JTextField();
        jTextCalendarXM1 = new JCalendarXM.JTextCalendarXM();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jLabelSequences.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelSequences.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jComboSequence.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jComboSequence.setToolTipText(TDSLanguageUtils.getMessage("jPanelAnimalData.jComboFather.toolTipText"));
        jComboSequence.setBorder(null);
        jComboSequence.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboSequenceActionPerformed(evt);
            }
        });

        jLabelSequences1.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences1.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelSequences1.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jLabelSequences3.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences3.setForeground(java.awt.SystemColor.activeCaption);
        jLabelSequences3.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabelSequences3.setText("01-02-2014");
        jLabelSequences3.setToolTipText("");

        jLabelSequences2.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences2.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelSequences2.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jSeparator1.setBackground(java.awt.SystemColor.menuText);
        jSeparator1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jSeparator1.setMinimumSize(new java.awt.Dimension(50, 5));
        jSeparator1.setOpaque(true);
        jSeparator1.setPreferredSize(new java.awt.Dimension(50, 5));

        jScrollPaneTable.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                jScrollPaneTableKeyPressed(evt);
            }
        });

        jLabelSequences4.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences4.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelSequences4.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jTextDuration.setFont(new java.awt.Font("Tahoma", 2, 14)); // NOI18N
        jTextDuration.setHorizontalAlignment(javax.swing.JTextField.RIGHT);
        jTextDuration.setToolTipText(TDSLanguageUtils.getMessage("jPanelAnimalData.jTextSearchMother.toolTipText"));
        jTextDuration.setAlignmentX(0.0F);
        jTextDuration.setAlignmentY(0.0F);
        jTextDuration.setMinimumSize(new java.awt.Dimension(36, 36));
        jTextDuration.setPreferredSize(new java.awt.Dimension(36, 36));
        jTextDuration.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextDurationActionPerformed(evt);
            }
        });

        jLabelSequences5.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences5.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
        jLabelSequences5.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jSeparator2.setBackground(java.awt.SystemColor.menuText);
        jSeparator2.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        jSeparator2.setMinimumSize(new java.awt.Dimension(50, 5));
        jSeparator2.setOpaque(true);
        jSeparator2.setPreferredSize(new java.awt.Dimension(50, 5));

        jButtonExit.setIcon(new javax.swing.ImageIcon(getClass().getResource("/xmarti/vacaxm/image/BotoSortir.png"))); // NOI18N
        jButtonExit.setText(TDSLanguageUtils.getMessage("jDialogXM.JButton.exit.caption"));
        jButtonExit.setToolTipText(TDSLanguageUtils.getMessage("jDialogXM.JButton.exit.toolTipText"));
        jButtonExit.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonExit.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonExit.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonExitActionPerformed(evt);
            }
        });

        jButtonSave2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/xmarti/vacaxm/image/BotoGuardar.png"))); // NOI18N
        jButtonSave2.setText(TDSLanguageUtils.getMessage("jDialogXM.JButton.save.caption"));
        jButtonSave2.setToolTipText(TDSLanguageUtils.getMessage("jDialogXM.JButton.save.toolTipText"));
        jButtonSave2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButtonSave2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButtonSave2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButtonSave2ActionPerformed(evt);
            }
        });

        jLabelDescriptionSequence.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelDescriptionSequence.setForeground(java.awt.SystemColor.activeCaption);
        jLabelDescriptionSequence.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        jLabelDescriptionState.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
        jLabelDescriptionState.setForeground(java.awt.SystemColor.activeCaption);
        jLabelDescriptionState.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        jLabelSequences6.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
        jLabelSequences6.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
        jLabelSequences6.setText(TDSLanguageUtils.getMessage("jPanelSequenceType.JLabel.availables.caption"));

        jTextName.setFont(new java.awt.Font("Tahoma", 2, 14)); // NOI18N
        jTextName.setToolTipText(TDSLanguageUtils.getMessage("jPanelAnimalData.jTextSearchMother.toolTipText"));
        jTextName.setAlignmentX(0.0F);
        jTextName.setAlignmentY(0.0F);
        jTextName.setMinimumSize(new java.awt.Dimension(36, 36));
        jTextName.setPreferredSize(new java.awt.Dimension(36, 36));
        jTextName.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextNameActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelSequences, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelSequences1, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelSequences2, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jComboSequence, javax.swing.GroupLayout.PREFERRED_SIZE, 192, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelSequences3, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextCalendarXM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(21, 21, 21)
                        .addComponent(jLabelDescriptionSequence, javax.swing.GroupLayout.PREFERRED_SIZE, 328, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 676, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 676, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(10, 10, 10)
                .addComponent(jScrollPaneTable, javax.swing.GroupLayout.PREFERRED_SIZE, 284, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabelSequences6, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelSequences4, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jTextDuration, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabelSequences5, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jTextName, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDescriptionState, javax.swing.GroupLayout.PREFERRED_SIZE, 203, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addGap(83, 83, 83)
                .addComponent(jButtonSave2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButtonExit)
                .addGap(59, 59, 59))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(11, 11, 11)
                        .addComponent(jLabelSequences)
                        .addGap(29, 29, 29)
                        .addComponent(jLabelSequences1)
                        .addGap(10, 10, 10)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabelSequences2)
                            .addComponent(jLabelSequences3, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jComboSequence, javax.swing.GroupLayout.PREFERRED_SIZE, 36, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jTextCalendarXM1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(4, 4, 4)
                        .addComponent(jLabelDescriptionSequence, javax.swing.GroupLayout.PREFERRED_SIZE, 120, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(10, 10, 10)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelSequences6))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jTextDuration, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelSequences4)
                            .addComponent(jLabelSequences5))
                        .addGap(18, 18, 18)
                        .addComponent(jLabelDescriptionState, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(jScrollPaneTable, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(20, 20, 20)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jButtonSave2)
                        .addGap(7, 7, 7))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(jButtonExit)
                        .addContainerGap())))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jComboSequenceActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboSequenceActionPerformed
            if (jComboSequence.getSelectedIndex()==-1){
                this.sequenceType= new SequenceType(); 
            }
            else if (jComboSequence.getSelectedIndex()>0){
               this.sequenceType= (SequenceType) jComboSequence.getSelectedItem();              
                try { 
                    setDataSequence();
                } catch (ExceptionHibernateVacaxm ex) {
                    Logger.getLogger(JDNewSequence.class.getName()).log(Level.SEVERE, null, ex);
                }
           }else{                       
               this.jComboSequence.setSelectedIndex(-1);

           }            
    }//GEN-LAST:event_jComboSequenceActionPerformed

    private void jButtonExitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonExitActionPerformed
        this.dispose();
    }//GEN-LAST:event_jButtonExitActionPerformed

    private void jButtonSave2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButtonSave2ActionPerformed
        //todo button save
    }//GEN-LAST:event_jButtonSave2ActionPerformed

    private void jTextNameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextNameActionPerformed
        try {
            this.stateDefault.getState().setName(this.jTextName.getText());
            this.jTable.chargeModel(this.getModel());
        } catch (ExceptionHibernateVacaxm ex) {
            Logger.getLogger(JDNewSequence.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jTextNameActionPerformed

    private void jTextDurationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextDurationActionPerformed
        try {
            this.stateDefault.getState().setDuration(Integer.parseInt(this.jTextDuration.getText()));
            this.jTable.chargeModel(this.getModel());
        } catch (ExceptionHibernateVacaxm ex) {
            Logger.getLogger(JDNewSequence.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jTextDurationActionPerformed

    private void jScrollPaneTableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jScrollPaneTableKeyPressed
        if (evt.getKeyCode()==13) this.jTextName.requestFocus();
    }//GEN-LAST:event_jScrollPaneTableKeyPressed

     private void selectionEvent(ListSelectionEvent e){           
        if(this.jTable.getSelectedRow()>-1){                                            
            this.stateDefault=(StateDefault) this.jTable.getValueAt(this.jTable.getSelectedRow(),0);                 
            this.jTextDuration.setText(""+ this.stateDefault.getState().getDuration()); 
            this.jTextName.setText(this.stateDefault.getState().getName());
        }                                                                 
   }
private TableModel getModel() throws ExceptionHibernateVacaxm{        
        
        TableModel dadesTaula = null;                
        //this.states=(List<StateDefault>)this.implSequence.getStatesDefault(this.sequenceType);
        this.states=this.sequenceType.getStates();
            String [] columns={"ESTAT","DURACIO (DIES)"};    
            Object[][] dades=null;
            if (this.states.size()==0){
                dades=new Object[1][columns.length];                          
                dades[0][0]=new StateDefault();
                dades[0][1]="-";
            }
            else{
                dades=new Object[this.states.size()][columns.length];                          
                Integer i=0;            
                for (Iterator it = this.states.iterator(); it.hasNext();) {                    
                    StateDefault c = (StateDefault) it.next();                                    
                    dades[i][0]=(StateDefault) c;                    
                    dades[i][1]= c.getState().getDuration();
                    i++;
                }     
            }
                
            dadesTaula=new TableModel(columns, dades);                       
        
        return dadesTaula;        
    }
 
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButtonExit;
    private javax.swing.JButton jButtonSave2;
    private javax.swing.JComboBox jComboSequence;
    private javax.swing.JLabel jLabelDescriptionSequence;
    private javax.swing.JLabel jLabelDescriptionState;
    private javax.swing.JLabel jLabelSequences;
    private javax.swing.JLabel jLabelSequences1;
    private javax.swing.JLabel jLabelSequences2;
    private javax.swing.JLabel jLabelSequences3;
    private javax.swing.JLabel jLabelSequences4;
    private javax.swing.JLabel jLabelSequences5;
    private javax.swing.JLabel jLabelSequences6;
    private javax.swing.JScrollPane jScrollPaneTable;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JSeparator jSeparator2;
    private JCalendarXM.JTextCalendarXM jTextCalendarXM1;
    private javax.swing.JTextField jTextDuration;
    private javax.swing.JTextField jTextName;
    // End of variables declaration//GEN-END:variables
}
